import db from '~~/DB';
import { defineResponseResolver } from '~~/mocks/define';
import { validateMenu } from '~~/mocks/middleware/menu';

export default validateMenu('system-menu-key', async (req, res, ctx) => {
  const menu = await db.menus.get(req.params.key);
  if (!menu) {
    // const menus = await db.menus.toCollection().sortBy('sort');
    return res(ctx.status(404), ctx.json({ message: '数据不存在' }));
  }
  return res(ctx.json(menu));
});
